﻿//ChartIndicatorValue.cs
//Copyright (c) 2013 StockSharp LLC, all rights reserved.
//This code module is part of StockSharp library.
//This code is licensed under the GNU GENERAL PUBLIC LICENSE Version 3.
//See the file License.txt for the license details.
//More info on: http://stocksharp.com

namespace StockSharp.Xaml
{
	using System;

	using StockSharp.Algo.Indicators;

	/// <summary>
	/// Графическое значение индикатора, содержащее в себе информацию о сформированности индикатора <see cref="IsFormed"/> и его значение <see cref="Value"/>.
	/// </summary>
	public class ChartIndicatorValue
	{
		/// <summary>
		/// Создать <see cref="ChartIndicatorValue"/>.
		/// </summary>
		/// <param name="indicator">Индикатор.</param>
		public ChartIndicatorValue(IIndicator indicator)
			: this(indicator, indicator.GetValue<IIndicatorValue>(0))
		{
		}

		/// <summary>
		/// Создать <see cref="ChartIndicatorValue"/>.
		/// </summary>
		/// <param name="indicator">Индикатор.</param>
		/// <param name="value">Значение индикатора.</param>
		public ChartIndicatorValue(IIndicator indicator, decimal value)
			: this(indicator, new DecimalIndicatorValue(value))
		{
		}

		/// <summary>
		/// Создать <see cref="ChartIndicatorValue"/>.
		/// </summary>
		/// <param name="indicator">Индикатор.</param>
		/// <param name="value">Значение индикатора.</param>
		public ChartIndicatorValue(IIndicator indicator, IIndicatorValue value)
		{
			if (indicator == null)
				throw new ArgumentNullException("indicator");

			if (value == null)
				throw new ArgumentNullException("value");

			Indicator = indicator;
			Value = value;
			IsFormed = indicator.IsFormed;
		}

		/// <summary>
		/// Индикатор.
		/// </summary>
		public IIndicator Indicator { get; private set; }

		/// <summary>
		/// Значение индикатора.
		/// </summary>
		public IIndicatorValue Value { get; private set; }

		/// <summary>
		/// Сформирован ли индикатор.
		/// </summary>
		public bool IsFormed { get; set; }
	}
}